/**
 * Created by henian.xu on 2021/7/10.
 *
 */

import { rawDataMixin } from 'store/mixins';
import { Http } from '@/api';

export default rawDataMixin({
  namespaced: true,
  state: {},
  getters: {
    initInfo(state, getters) {
      return getters.rawData || {};
    },
    // //状态  1：未中奖  2：已中奖  3：未抽奖
    drawStatus(state, getters) {
      const { initInfo } = getters;
      return initInfo.status || 0;
    },
    userInfo(state, getters) {
      const { initInfo } = getters;
      return initInfo.info || {};
    },
    activityStartTime(state, getters) {
      const { initInfo } = getters;
      return (initInfo.date_activity || {}).start;
    },
    activityEndTime(state, getters) {
      const { initInfo } = getters;
      return (initInfo.date_activity || {}).end;
    },
  },
  mutations: {},
  actions: {
    async update({ commit }) {
      const { data } = await Http.get('/api/dell_summer21_draw/getInitInfo');
      commit('_setRawData', data);
      // commit('_setRawData', { data: 1 });
    },
  },
});
